package com.cx.mq.rabbitmq.topic;

import com.cx.common.constant.MqConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:chenxiaoyi
 * @Date:2020/8/11 16:52
 */
@Configuration
public class TopicConfig {

    /**
     * 主题交换机
     */
    @Bean
    Exchange topicExchange(){
        return new TopicExchange(MqConstant.Exchange.TOPIC);
    }
    @Bean
    Queue queuetA(){
        return new Queue(MqConstant.Queue.T_QUEUE_A);
    }
    @Bean
    Queue queuetB(){
        return new Queue(MqConstant.Queue.T_QUEUE_B);
    }

    @Bean
    Binding bindingtA(){
        return BindingBuilder.bind(queuetA()).to(topicExchange()).with(MqConstant.RoutingKey.T_ROUTINGKEY_DYNAMIC).noargs();
    }

    @Bean
    Binding bindingtB(){
        return BindingBuilder.bind(queuetA()).to(topicExchange()).with(MqConstant.RoutingKey.T_ROUTINGKEY_LAST).noargs();
    }

}
